#用来写装饰器

from functools import wraps
from flask import request, jsonify, abort,g,url_for,redirect
#检测有无登录
def login_required(f):
    @wraps(f)
    def inner(*args, **kwargs):
        if g.user:
            return f(*args, **kwargs)
        else:
            return redirect(url_for('auth.login'))
    return inner